package wyh.controller.Escort;

import com.fasterxml.jackson.databind.ObjectMapper;
import wyh.pojo.Escort;
import wyh.service.EscortService;
import wyh.vo.Result;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

//9666666666666666666 ok
@WebServlet("/Escort/get")
public class GetAllServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        EscortService service = new EscortService();
        List<Escort> userList = service.ServicegetAll();
        Result result= new Result(200,"查询成功",userList);
        ObjectMapper ojmapper = new ObjectMapper();
        String json = ojmapper.writeValueAsString(result);
        resp.setContentType("application/json;charset=utf-8");
        resp.getWriter().write(json);
    }
}
